package com.xjrsoft.module.visual.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.core.tool.utils.StringPool;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.base.dto.GetPageListDto;
import com.xjrsoft.module.visual.entity.XjrVisualReleaseRelation;
import com.xjrsoft.module.visual.mapper.XjrVisualReleaseRelationMapper;
import com.xjrsoft.module.visual.service.IXjrVisualReleaseRelationService;
import com.xjrsoft.module.visual.vo.VisualReleaseHomeVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * BI发布权限表 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-03-15
 */
@Service
public class XjrVisualReleaseRelationServiceImpl extends ServiceImpl<XjrVisualReleaseRelationMapper, XjrVisualReleaseRelation> implements IXjrVisualReleaseRelationService {


    @Override
    public List<VisualReleaseHomeVo> getVisualOfRelationObject(String objectId, Integer category) {
        return this.baseMapper.getVisualOfRelationObject(objectId, category, null, null,0);
    }

    @Override
    public PageOutput<VisualReleaseHomeVo> getRelationVisualOfUser(String userId, List<String> roleIds, GetPageListDto dto) {
        String keyword = dto.getKeyword();
        if (!StringUtil.isEmpty(keyword)) {
            keyword = StringPool.PERCENT + keyword + StringPool.PERCENT;
        }
        IPage<VisualReleaseHomeVo> page = ConventPage.getPage(dto);
        roleIds.add("");
        List<VisualReleaseHomeVo> resultList = this.baseMapper.getVisualOfRelationObject(userId, 1, roleIds, keyword,null,page);
        return ConventPage.getPageOutput(page.getTotal(), resultList);
    }
}
